package cn.laoma.thread5.t5_003_Concurrent_Container;

import lombok.SneakyThrows;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.PriorityBlockingQueue;

/**
 * @program: ThreadDemos
 * @description: 具有优先级阻塞队列
 * 1.底层数据结构是用数组实现
 * 2.默认实现了Comparator
 * 3.底层采用二叉树来实现
 * @author: 老马
 * @create: 2021-10-02 16:47
 **/
public class T06_PriorityQueue {
    @SneakyThrows
    public static void main(String[] args) {
        Queue<String> queue = new PriorityQueue<>();
        queue.offer("d");
        queue.offer("c");
        queue.offer("a");
        queue.offer("b");

        //遍历元素打印
        queue.stream().forEach(System.out::println);

    }
}
